HAL CCB initialization and configuration functions migration ¶
The goal of this page is to show how to migrate the initialization sequence using STM32CubeMX2:
Open STM32CubeMX2 CCB configuration panel.
Configure the SW layer HAL.
Generate the code.
HAL CCB configuration panel ¶
Create a new project with the STM32CubeMX2, then start the initialization.
Generated CCB initialization and de-initialization sequences ¶
The CCB initialization sequence is generated in the
mx_ccb_init
function in
mx_ccb.c
file under
$YOUR_PROJECT_NAME$/$YOUR_PROJECT_NAME$_SW/generated/STM32Cube_CodeGen.
Related concepts:
|
Topic |
Code Snippet HAL1 |
Code Snippet HAL2 |
|---|---|---|
|
Handle declaration |
CCB_HandleTypeDef hccb;
|
static hal_ccb_handle_t hCCB;
|
|
Initialization sequence |
static void MX_CCB_Init(void)
{
hccb.Instance = CCB;
if (HAL_CCB_Init(&hccb) != HAL_OK)
{
Error_Handler();
}
}
void HAL_CCB_MspInit(CCB_HandleTypeDef* hccb)
{
if(hccb->Instance==CCB)
{
__HAL_RCC_CCB_CLK_ENABLE();
__HAL_RCC_PKA_CLK_ENABLE();
__HAL_RCC_SAES_CLK_ENABLE();
__HAL_RCC_RNG_CLK_ENABLE();
}
}
|
hal_ccb_handle_t *mx_ccb_init(void)
{
if (HAL_CCB_Init(&hCCB, HAL_CCB) != HAL_OK)
{
return NULL;
}
HAL_RCC_CCB_EnableClock();
HAL_RCC_PKA_EnableClock();
HAL_RCC_SAES_EnableClock();
/* Enable RNG clock is mandatory for SAES */
HAL_RCC_RNG_EnableClock();
return &hCCB;
}
|
|
Deinitialization sequence |
void HAL_CCB_MspDeInit(CCB_HandleTypeDef* hccb)
{
if(hccb->Instance==CCB)
{
__HAL_RCC_CCB_CLK_DISABLE();
__HAL_RCC_PKA_CLK_DISABLE();
__HAL_RCC_SAES_CLK_DISABLE();
__HAL_RCC_RNG_CLK_DISABLE();
}
}
|
void mx_ccb_deinit(void)
{
HAL_CCB_DeInit(&hCCB);
HAL_RCC_CCB_Reset();
HAL_RCC_CCB_DisableClock();
HAL_RCC_PKA_DisableClock();
}
|